﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.EquipmentManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.EquipmentManagement.EquipmentSpotItemVMs
{
    public partial class EquipmentSpotItemTemplateDetailListVM1 : BasePagedListVM<EquipmentSpotItem, EquipmentSpotItemDetailSearcher1>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("EquipmentSpotItem", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("EquipmentSpotItem", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<EquipmentSpotItem>> InitGridHeader()
        {
            return new List<GridColumn<EquipmentSpotItem>>{
                
                this.MakeGridHeader(x => x.SpotType).SetEditType(EditTypeEnum.ComboBox,typeof(SpotTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.点检类型"].Value),
                this.MakeGridHeader(x => x.Content).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.点检内容"].Value),
                this.MakeGridHeader(x => x.Active).SetEditType(EditTypeEnum.ComboBox,Utils.GetBoolCombo(BoolComboTypes.YesNo, selectText:Wtm.Localizer?["Sys.PleaseSelect"])).SetTitle(@Localizer["Page.激活"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<EquipmentSpotItem> GetSearchQuery()
        {
                
            var id = (long?)Searcher.TemplateId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<EquipmentSpotItem>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<EquipmentSpotItem>()
                .Where(x => id == x.TemplateId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class EquipmentSpotItemDetailSearcher1 : BaseSearcher
    {
        
        [Display(Name = "_Model._EquipmentSpotItem._Template")]
        public string TemplateId { get; set; }
    }

}

